package dimension.starry.mixin;

import dimension.starry.gui.screen.MainScreen;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.RotatingCubeMapRenderer;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.server.network.ServerPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Environment(EnvType.CLIENT)
@Mixin(value = TitleScreen.class, priority = 1001)
public class TitleScreenMixin {

    @Redirect(
        method = "render",
        at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/RotatingCubeMapRenderer;render(FF)V")
    )
    private void deleteOldTitleScreenBackgroundRender(RotatingCubeMapRenderer instance, float delta, float alpha) {}

    @Inject(
        method = "render",
        at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/RotatingCubeMapRenderer;render(FF)V",
            shift = At.Shift.AFTER)
    )
    private void addTitleScreenBackgroundRender(
        DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci
    ) {
        MainScreen.renderBack(context);
    }


}
